package com.huibao.hulibao.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.huibao.hulibao.R;
import com.huibao.hulibao.entity.HuLiBindMomEntity;
import com.huibao.hulibao.utils.T;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by lizhaoyong on 2018/5/7.
 */
public class BindClientLvAdapter extends BaseAdapter {
    private ArrayList<HuLiBindMomEntity.MomData> mDatas;
    private Context mContext;

    private LayoutInflater mInflater;

    public BindClientLvAdapter(ArrayList<HuLiBindMomEntity.MomData> datas, Context context) {
        this.mDatas = datas;
        this.mContext = context;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public Object getItem(int position) {
        return mDatas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;

        HuLiBindMomEntity.MomData md = mDatas.get(position);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_lv_my_bind_client, parent, false);
            holder = new ViewHolder(convertView);
            // holder.mTextView = (TextView)convertView.findViewById(R.id.tv_title);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.tv_lv_client_name.setText("客户名:" + md.cname);
        holder.tv_lv_client_state.setText("状态:" + md.statename);
        holder.tv_lv_my_client_time.setText("建档时间:" + md.outtime);
        for (int i = 0; i < md.persons.size(); i++) {
            if (md.persons.get(i).IsMom.equals("0")) {
                holder.tv_lv_my_client_mom.setText("妈妈:" + md.persons.get(i).MatherName);
                holder.tv_lv_my_client_baby.setText("宝宝:" + md.persons.get(i).BabyName);
            }
        }
        // holder.mTextView.setText(mDatas.get(position));

        return convertView;
    }


    static class ViewHolder {


        @BindView(R.id.iv_lv_state)
        ImageView iv_lv_state;
        @BindView(R.id.tv_lv_client_name)
        TextView tv_lv_client_name;
        @BindView(R.id.tv_lv_client_state)
        TextView tv_lv_client_state;
        @BindView(R.id.tv_lv_my_client_mom)
        TextView tv_lv_my_client_mom;
        @BindView(R.id.tv_lv_my_client_baby)
        TextView tv_lv_my_client_baby;
        @BindView(R.id.tv_lv_my_client_time)
        TextView tv_lv_my_client_time;


        public ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
